<template>
  <div class="innerPage" v-if="Contentlist.orderCode">
    <div class="collect-info">
      {{ Contentlist.status == 1 ? "订单已完成" : Contentlist.status == 2 ? "订单已取消" : Contentlist.status == 0 ? "待买家付款" :
          "订单详情"
      }}

    </div>
    <van-row class="li">
      <van-col span="8">
        <div class="img-box">
          <img :src="Contentlist.collectionCover" class="img" v-if="VideoIndexOf(Contentlist.collectionCover)" />
          <div class="videoContainer" v-else>
            <vdeo :collection='Contentlist.collectionCover' class="video" />
          </div>
        </div>
      </van-col>
      <van-col span="10" class="line">
        <div class="record-cont">
          <h1>{{ Contentlist.collectionName }} </h1>
          <h2>{{ Contentlist.className ? Contentlist.className : "" }}</h2>
          <h2>购买数量：{{ Contentlist.number }}</h2>
        </div>
      </van-col>
      <van-col span="6" class="space-between">
        <p>￥ {{ Contentlist.amount }}</p>
      </van-col>
    </van-row>
    <div class="collect-info">
      认证信息
    </div>
    <van-row justify="end" class="colletion-authon">
      <van-col span="6">合约地址</van-col>
      <van-col span="18" class="right">
        <p v-if="Contentlist.assetId">{{ Contentlist.assetId }}</p>
        <img src="../../../assets/image/icon/copids.png" alt="" @click="copy">
      </van-col>
    </van-row>

    <div class="collect-info">
      订单详情
    </div>
    <div class="story">
      <p>实付金额：{{ Contentlist.amount }}</p>
      <p>支付方式：账户余额</p>
      <p>订单编号：<span>{{ Contentlist.orderCode }}</span> <img src="../../../assets/image/icon/copids.png" alt=""
          @click="copy1"></p>
      <p>创建时间：{{ Contentlist.createTime }} </p>
      <p v-if="Contentlist.payTime">支付时间：{{ Contentlist.payTime }}</p>
      <p v-if="Contentlist.cancelTime">取消时间：{{ Contentlist.cancelTime }}</p>
    </div>
    <div class="flex " v-if="Contentlist.status == 0">
      <van-button type="primary" class="cancel" @click="cancel">
        <span>取消订单</span>

      </van-button>
      <van-button type="primary" @click="openPwd" class="buy">
        <span>去付款</span>

      </van-button>
    </div>
    <!-- <van-row justify="space-between" class="footer" v-else>
      <van-col span="12" v-if="Contentlist.status==2">
        <span class="price">￥{{Contentlist.amount}}</span>
      </van-col>
      <van-col span="12" class="right">
        <van-button type="primary" v-if="Contentlist.status==2" class="seing buy">
          <span>已放弃支付</span>
        </van-button>
       
      </van-col>
    </van-row> -->
    <Pwdwarp ref="PwdShow" :paydata="paydata" />
  </div>

</template>
<script>
import { onMounted, ref, } from 'vue'
import Clipboard from 'clipboard';
import useClipboard from 'vue-clipboard3'
import { useStore } from "vuex";
import { useRouter } from "vue-router"
import { stringNum } from "@/utils/phone";
import { Toast } from "vant";
import Pwdwarp from "@/components/pwd.vue";
import { shoppingPay, getInfo, cancelPay } from "@/api/public";
import { VideoIndexOf, } from "@/utils/phone";
import vdeo from "@/components/video.vue";
export default {
  components: {
    Pwdwarp, vdeo
  },
  setup(props) {
    const store = useStore();
    const router = useRouter()
    const popupshow = ref(false)
    const { toClipboard } = useClipboard()
    const Contentlist = ref({})
    const onLoad = async () => {
      Toast.loading({
        message: '数据加载中...',
        forbidClick: true,
      });

      const data = { orderId: router.currentRoute.value.query.id }
      const res = await getInfo(data)
      if (res.data.success) {
        Toast.clear()
        Contentlist.value = res.data.data
        console.log(Contentlist.value)
      }


    }
    const paydata = ref({
      orderCode: Contentlist.value.orderCode,
      type: "3"
    })
    const PwdShow = ref(null)
    const openPwd = () => {
      paydata.value.orderCode = Contentlist.value.orderCode
      PwdShow.value.pwdopen = true
    }
    const cancel = () => {
      const data = {
        orderCode: Contentlist.value.orderCode,
      }
      cancelPay(data).then(res => {
        if (res.data.success) {
          Toast('操作成功')
          onLoad()
        } else {
          Toast(res.data.meaasge)
        }
      })
    }
    const copy = async () => {
      try {
        await toClipboard(Contentlist.value.assetId)
        Toast("复制成功")
      } catch (e) {
        console.error(e)
      }
    }
    const copy1 = async () => {
      try {
        await toClipboard(Contentlist.value.orderCode)
        Toast("复制成功")
      } catch (e) {
        console.error(e)
      }
    }
    onMounted(() => {
      onLoad()
    })
    return {
      popupshow, copy, openPwd, PwdShow, copy1, Contentlist, cancel, paydata, VideoIndexOf
    }
  }
}
</script>
<style lang="less" scoped>
.innerPage {
  .flex {
    margin-top: 80px;
    display: flex;
    justify-content: space-around;
    align-items: center;

    .cancel {
      width: 300px;
      height: 88px;
      background: #7d8184;
      border-radius: 44px;
      font-size: 32px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #ffffff;
      border: none;
    }

    .buy {
      width: 300px;
      height: 88px;
      background: linear-gradient(-90deg, #37dc6d, #34d1f9);
      border-radius: 44px;
      font-size: 32px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #ffffff;
      border: none;
    }
  }

  .story {
    p {
      display: flex;
      position: relative;
      font-size: 34px;
      font-family: Source Han Sans CN;
      font-weight: 300;
      color: #ffffff;
      line-height: 70px;

      span {
        font-size: 24px;
      }

      img {
        width: 40px;
        margin-left: 20px;
        height: 40px;
        position: absolute;
        right: 0px;
      }
    }
  }

  padding-bottom: 148px;

  .colletion-authon {
    padding: 0px 18px;
    font-size: 34px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ffffff;
    line-height: 120px;
    margin: 30px 20px 0px;
    background: #282a2c;
    border: 1px solid #999;
    border-bottom: 0px;
    box-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.35);
    border-radius: 20px;

    .right {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      text-align: right;

      p {
        width: 80%;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      p {
        font-size: 30px;
        font-family: Source Han Sans CN;
        font-weight: 300;
        color: #b9c4c7;
      }

      img {
        width: 40px;
        margin-left: 20px;
      }

      text-align: right;

      span {
        text-align: center;
        font-size: 30px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #fefefe;
        background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }

  .collect-info {
    .tip {
      font-size: 26px !important;
      font-family: Source Han Sans CN;
      font-weight: 300;
      color: #f8f8f8;

      span {
        background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }

    padding-right: 20px;
    display: flex;
    justify-content: space-between;
    z-index: 1;
    margin-top: 50px;
    font-size: 36px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #f8f8f8;
    margin-left: 20px;
    padding-left: 40px;
    position: relative;
  }

  .collect-info::after {
    opacity: 0.8;
    z-index: -1;
    background-size: 100% 100%;
    width: 70px;
    height: 60px;
    top: -10px;
    left: 0;
    position: absolute;
    content: '';
    background-image: url('../../../assets/image/point.png');
  }

  .li {
    display: flex;
    align-items: center;
    background: #282a2c;
    border-radius: 20px;
    margin: 30px 20px 0px;
    padding: 20px 20px;

    .videoContainer {
      .fullscreenVideo {
        width: 100%;
        height: 100%;
      }

      video {
        width: 200px;
        height: 200px;
      }

      width: 200px;
      height: 200px;
      background: linear-gradient(0deg, #161718, #4b4c4d);
      // border: 2px solid #999;
      border-radius: 20px;
      overflow: hidden;
    }

    .img-box {
      width: 200px;
      height: 200px;
      background: linear-gradient(0deg, #161718, #4b4c4d);
      border: 2px solid #999;
      border-radius: 20px;
      overflow: hidden;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .record-cont {
      margin-left: 20px;

      h1 {
        height: 30px;
        font-size: 32px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
        line-height: 53px;
        margin: 0px;
      }

      h2 {
        height: 25px;
        font-size: 26px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #b9c4c7;
        line-height: 48px;
        margin-top: 25px;
      }

      p {
        height: 20px;
        font-size: 26px;
        font-family: Source Han Sans CN;
        font-weight: 300;
        color: #b9c4c7;
        line-height: 48px;
      }
    }

    .space-between {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-end;

      span {
        font-size: 32px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
        line-height: 73px;

        background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }

      p {
        font-size: 40px;
        font-family: Source Han Sans CN;
        font-weight: bold;
        color: #ffffff;
        line-height: 73px;

        background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }

  .story {
    background: #282a2c;
    border: 1px solid #999;
    box-shadow: 0px 2px 16px 0px rgba(0, 0, 0, 0.35);
    border-radius: 20px;
    margin: 30px 30px;
    padding: 30px;
    font-size: 28px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ffffff;
    line-height: 48px;
  }

  .footer {
    width: 750px;
    padding: 30px 0px;
    background: #282a2c;
    position: fixed;
    bottom: 0px;
    z-index: 999;
    display: flex;
    align-items: center;

    .price {
      font-size: 46px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #f8f8f8;
      margin-left: 50px;
    }

    .right {
      padding-right: 20px;
      text-align: right;
      display: flex;
      justify-content: flex-end;
      // &:deep(.van-button) {

      // }
      .sed {
        border: none;
        border-radius: 62px;
        width: 256px;
        height: 74px;
        background: #7d8184 !important;
        border-radius: 32px;

        span {
          display: block;
          font-size: 28px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #ffffff;
          line-height: 26px;
        }
      }

      .buy {
        border: none;
        background: linear-gradient(-90deg, #37dc6d, #34d1f9);
        border-radius: 62px;
        width: 256px;
        height: 74px;

        span {
          display: block;
        }
      }
    }
  }
}

&:deep(.van-popup) {
  background: #000 !important;
}

.gift-warp {
  padding-top: 50px;

  i {
    top: 20px;
    right: 20px;
    position: absolute;
    color: #fefefe;
    font-size: 60px;
  }

  img {
    display: block;
    width: 625px;
    height: 415px;
    margin: 50px auto 0px;
  }

  .box-btn {
    font-size: 32px;
    display: block;
    border: none;
    width: 448px;
    height: 80px;
    background: linear-gradient(-90deg, #37dc6d, #34d1f9);
    margin: 20px auto;
  }

  h1 {
    text-align: center;
    font-size: 48px;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #f3e3bb;
    line-height: 42px;
    margin: 40px 0px;
  }

  width: 688px;
  height: 777px;
  background-image: url('../../../assets/image/giftbg.png');
  background-size: 100% 100%;
}
</style>